import React, { useState, useEffect, useRef, useMemo } from 'react';
import { useModel } from 'umi';
import getApiData from '@/services/cpasRequest';
import Popup from 'devextreme-react/popup';
import Button from 'devextreme-react/button';
import { DataGrid, SearchPanel, Column, Summary, TotalItem } from 'devextreme-react/data-grid';
import "./index.less"
import ErrorBounced from '@/pages/components/ErrorBounced/index';
import { CallingCpasexe, fjAndDgDataCode, intl, rTime, resDataFilter, syncCpasexeFJ } from '@/utils';
import ScrollView from 'devextreme-react/scroll-view';
import { openFile } from '@/utils/electronUtil';

import { importAttachFromPlatform, deleteAttach, replaceAttach, fjidRename, exportFjs } from './service';
import notify from 'devextreme/ui/notify';
import List from 'devextreme-react/list';
import { CpasIcon, DevPopup } from '~/public/cpas-ui';
import type { MenuProps } from 'antd';
import { Dropdown } from 'antd';
// import InputDialog from '../AuditPaper/components/InputDialog';
// import DevInputPopup from '~/public/cpas-ui/components-ui/express-components/DevPopup';

import AttributeDrawer from "./components/AttributeDrawer"
import { getCpasIcon } from '@/utils/icon';
import DevDefaultPopup from '~/public/cpas-ui/components-ui/express-components/DevPopup/DevPopup';
import { LoadIndicator } from 'devextreme-react';
import ErrorBouncedChangeName from '../components/ErrorBounced/errorBouncedChangeName';


const XMType = window.sessionStorage.electronParams
  ? JSON.parse(window.sessionStorage.electronParams)?.params?.XMType
  : "单机审计项目";

const ConfirmPopup = (props: {
  visible: boolean;
  onConfirm: () => void;
  onCancel: () => void;
  title: string;
  content: string;
}) => {
  return (
    <Popup
      visible={props?.visible}
      title={props?.title}
      onHiding={props?.onCancel}
      width={400}
      height={200}
      showTitle={true}
      showCloseButton={true}
      closeOnOutsideClick={true}
      contentRender={() => {
        return (
          <div>
            <div>{props?.content}</div>
            <div
              style={{
                display: 'flex',
                position: 'absolute',
                bottom: '10px',
                right: '20px',
              }}
            >
              <Button width={88} text={intl('paper.cancel', '取消')} onClick={props?.onCancel} />
              <Button
                type='default'
                width={88}
                style={{ marginRight: '10px' }}
                text={intl('paper.confirm', '确定')}
                onClick={props?.onConfirm}
              />
            </div>
          </div>
        );
      }}
    />
  );
};

async function getAttachList(dbname: string) {
  const res = await getApiData('dgfj.list', { dbname: dbname });
  let tempData = [];
  if (res.ok) {
    tempData = res.data.map((item: any) => {
      return {
        ...item,
        fullName: item.fjName + item.fjlx,
      };
    });
  }
  return Promise.resolve({
    data: tempData,
    success: res.ok,
  });

}


const AuditAttach = () => {
  const { initialState } = useModel('@@initialState');
  const { dbname, zcbfid, sjxmbh } = initialState?.curPart as API.CurPart;
  const { username, usercode, aesPassword } = initialState?.curUser as API.CurUser;
  const password = window.main.cryptoUtil(aesPassword);
  const [attachList, setAttachList] = useState<any[]>([]);
  // const [importPopup, setImportPopup] = useState(false);
  // const [filePaths, setFilePaths] = useState<string[]>([]);
  const InputDialogRef = useRef<any>(); // 模板
  const [openVisible111111, setOpenVisible111111] = useState<boolean>(false);

  const tplDialogRef = useRef<any>();
  const errorBouncedRefChangeNameRef = useRef<any>();
  const selRowDataRef = useRef<any>();
  const AttributeRef = useRef<any>();
  const DevSortableGridRef = useRef<any>();
  const Name = useRef<any>();

  const [deletePopupProps, setDeletePopupProps] = useState<{
    visible: boolean;
    onConfirm: () => void;
    onCancel: () => void;
    title: string;
    content: string;
  }>({
    visible: false,
    onConfirm: async () => { },
    onCancel: async () => { },
    title: '',
    content: '',
  });

  async function attachListRefresh() {
    setOpenVisible111111(true);

    const res = await getAttachList(dbname);
    if (res.success) {
      setAttachList(res.data);
      setOpenVisible111111(false);
    }
  }

  function closeDeletePopup() {
    setDeletePopupProps({
      visible: false,
      onConfirm: async () => { },
      onCancel: async () => { },
      title: '',
      content: '',
    });
  }

  useEffect(() => {
    attachListRefresh();
  }, []);

  const batchDelete = async (rowData: any) => {
    let fileIDList: any[] = [];
    if (rowData?.fjid) {
      fileIDList = [rowData.fjid];
    } else {
      fileIDList = DevSortableGridRef?.current?.instance?.getSelectedRowKeys();
    }
    if (fileIDList.length === 0) {
      notify(intl('audit.paper.delContent', '请选择要删除的文件'), 'error', 3000);
      closeDeletePopup();
      return;
    };
    setDeletePopupProps({
      visible: true,
      title: intl('audit.paper.del', '删除提醒'),
      content: rowData.fjid ? `确定要删除【${rowData.fjName}】吗？` : `共选择 ${fileIDList.length} 个,确定要删除吗？`,
      onConfirm: async () => {
        const res = await deleteAttach(fileIDList, dbname, zcbfid, sjxmbh);
        if (res) {
          closeDeletePopup();
          await attachListRefresh();
          DevSortableGridRef?.current?.instance?.clearSelection();
        }
      },
      onCancel: () => {
        closeDeletePopup();
      },
    });
  };



  const editFjName = async (newData: any) => {
    const r = await fjidRename(newData);
    if (r.success) {
      const resFilter = resDataFilter(r.data);
      if (resFilter.success) {
        const { reDataArr } = resFilter;
        if (reDataArr.tempError.length) {
          const resNew = fjAndDgDataCode(reDataArr.tempError[0].code);
          return notify(`${resNew}!`, 'error', 3000);
        }
        notify("重命名成功", "success", 2000);
        attachListRefresh();
      } else {
        notify('重命名失败', 'error', 2000);
      }
    } else {
      notify('重命名失败', 'error', 2000);
    }
  }



  const modalReplaceAttach = async (newData: any) => {
    const r = await replaceAttach(newData);
    if (r.success) {
      const resFilter = resDataFilter(r.data);
      if (resFilter.success) {
        const { reDataArr } = resFilter;
        if (reDataArr.tempError.length) {
          return tplDialogRef.current.show({
            args: {
              codes: true,
              data: reDataArr.tempError,
            },
          });
        }
        notify("替换文件成功", "success", 2000);
        attachListRefresh();
      } else {
        notify("替换文件失败", "error", 2000);
      }
    } else {
      notify("替换文件失败", "error", 2000);
    }
  }

  // 选中当前行
  const tableSelectRowID = async (tempFjID: string = '') => {
    let selID = '';
    if (tempFjID) {
      selID = tempFjID;
    } else {
      selID = selRowDataRef.current.fjid;
    }
    await DevSortableGridRef.current?.instance.selectRows(selID);
  }

  function relationMenuItems(e: any) {
    if (!e.row) return;
    tableSelectRowID(e.row.key);
    // 数据上的菜单
    if (e.target == 'content' && e.row?.rowType == 'data') {
      const rowData: any = e.row?.data;
      if (!rowData.fjid) return;

      e.items = [
        {
          icon: 'iconfont icon-dakai',
          text: intl('paper.open', '打开'),
          onItemClick: async () => {
            openFile([sjxmbh, zcbfid, '底稿附件', rowData.fullName].join('/'));
          },
        },
        {
          icon: 'iconfont icon-zhongmingming',
          text: intl('audit.paper.rename', '重命名'),
          onItemClick: () => {
            InputDialogRef.current.show({
              title: '附件重命名',
              value: rowData.fjName,
              regExpFunc: (v: any) => {
                let reg = /^[\s\S]*.*[^\s][\s\S]*$/;
                if (reg.test(v)) {
                  return true;
                } else {
                  notify('阶段名称不能有.后缀！', 'warning', 2000);
                  return false;
                }
              },
              okCallback: (value: any) => {
                editFjName({ sjxmbh, dbname, zcbfid, fjid: rowData.fjid, rename: value, refjlx: rowData.fjlx });
              }
            });
          },
        },
        {
          icon: 'iconfont icon-delete',
          text: intl('audit.paper.del', '删除'),
          onItemClick: async () => {
            batchDelete(rowData);
          },
        },
        // {
        //   icon: 'movetofolder',
        //   text: intl('audit.paper.move', '移动到'),
        //   onItemClick: () => {
        //   }
        // },
        {
          icon: 'iconfont icon-tihuan',
          text: intl('attach.replace', '替换'),
          onItemClick: async () => {
            const fileIDList = [rowData.fjid];
            if (fileIDList.length === 0) {
              notify(intl('attach.replaceTo', '请选择要替换的文件'), 'error', 3000);
              return;
            }
            const result = await window.electronComponents.openFilesDialog();
            if (result.canceled) return;
            if (result.filePaths.length === 0) {
              notify(intl('attach.replaceFrom', '请选择替换的文件'), 'error', 3000);
              return;
            } else if (result.filePaths.length !== 1) {
              notify(intl('attach.replace', '只能选择一个文件替换'), 'error', 3000);
              return;
            }
            await modalReplaceAttach({ filePaths: result.filePaths, fjids: fileIDList, dbname, zcbfid, sjxmbh });

          },
        },
        {
          icon: 'iconfont icon-er-digaomoban',
          text: intl('paper.draft', '底稿'),
          onItemClick: () => {
            AttributeRef.current.show(rowData, 'draft');
          },
        },
        {
          icon: 'iconfont icon-shuxing',
          text: intl('paper.props', '属性'),
          onItemClick: () => {
            AttributeRef.current.show(rowData, 'props');
          },
        },
      ];
    }
  }
  const dropdownItems: MenuProps['items'] = [
    {
      key: '0',
      label: '打开',
      className: "DropdownMenuStyle",
      icon: <CpasIcon type='icon-dakai' fontSize={18} />,
      onClick: async () => {
        await tableSelectRowID(selRowDataRef.current.fjid);
        openFile([sjxmbh, zcbfid, '底稿附件', selRowDataRef.current.fullName].join('/'));
      },
    },
    {
      key: '1',
      label: '重命名',
      className: "DropdownMenuStyle",
      icon: <CpasIcon type='icon-zhongmingming' fontSize={18} />,
      onClick: async () => {
        await tableSelectRowID(selRowDataRef.current.fjid);
        InputDialogRef.current.show({
          title: '附件重命名',
          value: selRowDataRef.current.fjName,
          regExpFunc: (v: any) => {
            let reg = /^[\s\S]*.*[^\s][\s\S]*$/;
            if (reg.test(v)) {
              return true;
            } else {
              notify('阶段名称不能有.后缀！', 'warning', 2000);
              return false;
            }
          },
          okCallback: async (value: any) => {
            editFjName({ sjxmbh, dbname, zcbfid, fjid: selRowDataRef.current.fjid, rename: value, refjlx: selRowDataRef.current.fjlx });
          }
        });
      }
    },

    {
      key: '2',
      className: "DropdownMenuStyle",
      icon: <CpasIcon type='icon-tihuan' fontSize={18} />,
      label: intl('paper.replace', '替换'),
      onClick: async () => {
        await tableSelectRowID(selRowDataRef.current.fjid);


        const fileIDList = [selRowDataRef.current.fjid];
        if (fileIDList.length === 0) {
          notify(intl('attach.replaceTo', '请选择要替换的文件'), 'error', 3000);
          return;
        }
        const result = await window.electronComponents.openFilesDialog();
        if (result.canceled) return;
        if (result.filePaths.length === 0) {
          notify(intl('attach.replaceFrom', '请选择替换的文件'), 'error', 3000);
          return;
        } else if (result.filePaths.length !== 1) {
          notify(intl('attach.replace', '只能选择一个文件替换'), 'error', 3000);
          return;
        }
        await modalReplaceAttach({ filePaths: result.filePaths, fjids: fileIDList, dbname, zcbfid, sjxmbh });

      }
    },
    {
      key: '4',
      label: '属性',
      className: "DropdownMenuStyle",
      icon: <CpasIcon type='icon-shuxing' fontSize={18} />,
      onClick: async () => {
        await tableSelectRowID(selRowDataRef.current.fjid);
        AttributeRef.current.show(selRowDataRef.current, 'props');
      }
    },

  ];
  const cellRenderCilk = (cell: any) => {
    return <div style={{ display: "flex", alignItems: 'center', justifyContent: 'center', }}>
      <div className="Icon_Style">
        <CpasIcon type='icon-delete' onClick={async () => {
          await tableSelectRowID(cell.data.fjid);
          batchDelete(cell.data);
        }} />
      </div>
      <div className="Icon_Style">
        <CpasIcon type='icon-attach' onClick={() => {
          AttributeRef.current.show(cell.data, 'draft');
        }} />
      </div>
      <div className="Icon_Style">
        <Dropdown menu={{ items: dropdownItems }}
          onOpenChange={() => {
            selRowDataRef.current = cell.data;
          }}

        >
          <i className='iconfont icon-ellipsis' />
        </Dropdown>
      </div>

    </div >
  }



  const loadIndicatorTemp = useMemo(() => {
    return (<> {openVisible111111 && <div style={{
      position: 'absolute', top: "0px", left: "0px", width: '100%', height: '100%', display: 'flex', alignItems: "center", justifyContent: "center", borderRadius: '5px',
      opacity: 0.5, zIndex: "9", background: "#ddd"
    }}>
      <LoadIndicator id="medium-indicator" height={50} width={50} />
    </div>} </>)
  }, [openVisible111111]);

  return (
    <div style={{ width: '100%', height: 'calc(100vh - 54px)', position: 'relative' }}>
      <DataGrid
        width='100%'
        height="100%"
        ref={DevSortableGridRef}
        className='PaperDevSortableGrid devHeadersCenter footerCount'
        dataSource={attachList}
        keyExpr="fjid"
        allowColumnReordering={true}
        hoverStateEnabled={true}
        showBorders={true}
        showRowLines={true}
        showColumnLines={true}
        allowColumnResizing={true}
        columnChooser={{ enabled: true }}
        columnFixing={{ enabled: true }}
        onContextMenuPreparing={relationMenuItems}
        onCellDblClick={(r: any) => {
          if (!r.data) return;
          openFile([sjxmbh, zcbfid, '底稿附件', r.data.fullName].join('/'));
        }}
        onCellClick={(r: any) => {
          console.log(r, 'r-----------------');
          Name.current = r.data
        }}
        searchPanel={{
          visible: true,
          width: 230,
          placeholder: ' ',
        }}
        selection={{
          mode: 'multiple',
          selectAllMode: 'page',
          showCheckBoxesMode: 'onClick',
        }}
        paging={{
          enabled: false,
        }}
        loadPanel={{ enabled: true }}
        toolbar={{
          items: [
            {
              location: 'before',
              text: '附件管理',
            },
            {
              cssClass: 'attachmentButton',
              location: 'after',
              widget: 'dxButton',
              options: {
                text: intl('paper.import', '导入文件'),
                primary: true,
                type: "default",
                stylingMode: "outlined",
                onClick: async () => {
                  const result = await window.electronComponents.openFilesDialog();
                  if (result.canceled) return;
                  const res = await importAttachFromPlatform(
                    result.filePaths,
                    dbname,
                    zcbfid,
                    username,
                    usercode,
                    "0",
                    sjxmbh,
                    '',
                    '',
                  );
                  if (res.success) {
                    const resFilter = resDataFilter(res.data);
                    if (resFilter.success) {
                      const { reDataArr } = resFilter;
                      if (reDataArr.tempSucc.length) {
                        notify('导入成功', 'success', 2000);
                        await attachListRefresh();
                        // if (XMType === '单机审计项目') return;
                        // reDataArr.tempSucc.forEach((item: any) => {
                        //   syncCpasexeFJ({
                        //     usercode,
                        //     password,
                        //     zcbfid,
                        //     BusType: 1,
                        //     BusID: item.fj
                        //   });
                        // });
                      };
                      if (reDataArr.tempError.length) {
                        return errorBouncedRefChangeNameRef.current.show({
                          args: {
                            codes: true,
                            dbname,
                            dgnd: '',
                            pupopType: 'fj',
                            data: reDataArr.tempError,
                          },
                          okCallback: async (tempData: any[]) => {
                            // console.log(tempData, '@@@ okCallback');
                            if (tempData.length > 0) {
                              const resUpdate = await importAttachFromPlatform(
                                tempData[1],
                                dbname,
                                zcbfid,
                                username,
                                usercode,
                                "0",
                                sjxmbh,
                                '', '',
                                tempData[0],
                              );
                              if (resUpdate.success) {
                                const resFilterUpdate = resDataFilter(resUpdate.data);
                                if (resFilterUpdate.success) {
                                  const { reDataArr } = resFilterUpdate;
                                  if (reDataArr.tempSucc.length) {
                                    notify('导入成功', 'success', 2000);
                                    await attachListRefresh();
                                    if (XMType === '单机审计项目') return;
                                    // reDataArr.tempSucc.forEach((item: any) => {
                                    //   syncCpasexeFJ({
                                    //     usercode,
                                    //     password,
                                    //     zcbfid,
                                    //     BusType: 1,
                                    //     BusID: item.fj
                                    //   });
                                    // });
                                  };
                                }
                              } else {
                                notify('导入失败', 'error', 3000);
                              }
                            } else {
                              await attachListRefresh();
                            }
                          },
                          cancelCallback: () => {
                            attachListRefresh();
                          },
                        });
                      }
                    } else {
                      notify('导入失败', 'error', 2000);
                    }
                  } else {
                    notify('导入失败', 'error', 2000);
                  }
                }
              },
            },
            {
              cssClass: 'attachmentButton',
              location: 'after',
              widget: 'dxButton',
              options: {
                text: intl('paper.import', '导出文件'),
                type: "default",
                stylingMode: "outlined",
                onClick: async () => {
                  const selectRowsData: any[] = DevSortableGridRef?.current?.instance?.getSelectedRowsData();
                  console.log(selectRowsData, '@@@');

                  if (selectRowsData?.length) {
                    let electronComponents: any;
                    if (window.parent) {
                      electronComponents = window.parent.electronComponents;
                    } else {
                      electronComponents = window.electronComponents;
                    }
                    const dialog_result = await electronComponents.openDirectoryDialog();
                    if (dialog_result.canceled) return;
                    const checkFolderPath = dialog_result.filePaths[0];
                    console.log(checkFolderPath, 'checkFolderPath-----------');
                    const names = selectRowsData.map(item => item.fullName).filter(name => name);
                    const r = await exportFjs(
                      sjxmbh,
                      dbname,
                      names,
                      checkFolderPath,
                    );
                    if (r.success) {
                      notify("导出附件成功", "success", 2000)
                    } else {
                      notify("导出失败", "error", 2000)
                    }
                  } else {
                    notify("至少选择一个", "error", 2000)
                  }
                },
              }
            },
            {
              cssClass: 'attachmentButton',
              location: 'after',
              widget: 'dxButton',
              visible: XMType === '单机审计项目' ? false : true,
              options: {
                text: '同步',
                onClick: () => {
                  CallingCpasexe({
                    usercode,
                    password,
                    zcbfid,
                    BusType: 1,
                  })
                },
              }
            },
            {
              name: 'searchPanel',
              location: 'after',
            },
            {
              location: 'after',
              widget: 'dxButton',
              cssClass: 'refreshButton_Style',
              options: {
                icon: "iconfont icon-refresh",
                onClick: async () => {
                  attachListRefresh();
                },
              },
            },
            {
              cssClass: 'PaperMenuItems',
              locateInMenu: 'always',
              widget: 'dxButton',
              options: {
                icon: 'iconfont icon-piliangshanchu',
                text: intl('paper.deleteAll', '批量删除'),
                onClick: () => {
                  batchDelete({});
                },
              },
            }
          ],
        }}
        columnMinWidth={100}
      >
        <SearchPanel visible={true} />
        <Column
          alignment='left'
          dataField="fjsyh"
          caption={intl('audit.attach.fjsyh', '附件索引号')}
          width={130}
        />
        <Column
          alignment='left'
          dataField="fullName"
          caption={intl('audit.attach.fjName', '附件名称')}
          cellRender={(cell) => {
            return (
              <div>
                <span style={{ marginRight: '5px' }}> {getCpasIcon(cell.data.fjlx)}</span>
                {cell.data.fullName}
              </div>
            );
          }}
        />
        <Column
          alignment='center'
          dataField="UserName"
          caption={intl('audit.attach.UserName', '编辑人')}
          width={120}
        />
        <Column
          alignment='center'
          dataField="LastEditDate"
          caption={intl('audit.attach.LastEditDate', '上次修改时间')}
          allowResizing={true}
          customizeText={(item: any) => {
            return rTime(item.value)
          }}
          width={200}
        />
        {/* <Column
            alignment='left'
            dataField="fjSize"
            caption={intl('audit.attach.fjSize', '附件大小')}
            allowResizing={true}
            width={120}
           /> */}
        <Column
          alignment='center'
          dataField="AddDate"
          caption={intl('audit.attach.AddDate', '添加日期')}
          customizeText={(item: any) => {
            return rTime(item.value)
          }}
          width={200}
        />
        <Column
          alignment='center'
          caption='操作'
          width={130}
          fixed={true}
          fixedPosition='right'
          cellRender={(cell) => cellRenderCilk(cell)}
        />

        <Summary>
          <TotalItem column="fjsyh" summaryType="count" />
        </Summary>
      </DataGrid>
      {loadIndicatorTemp}

      {/* 删除部分弹窗 */}
      <ConfirmPopup
        visible={deletePopupProps?.visible}
        onConfirm={deletePopupProps?.onConfirm}
        onCancel={deletePopupProps?.onCancel}
        title={deletePopupProps?.title}
        content={deletePopupProps?.content}
      />
      {/* 导入部分弹窗 */}
      {/* <Popup
        title={intl('audit.attach.del', '导入附件')}
        visible={importPopup}
        onHiding={() => {
          setImportPopup(false);
        }}
        resizeEnabled={true}
        contentRender={() => (
          <div style={{ display: 'block', justifyContent: 'center', height: '80%' }}>
            <div style={{ display: 'block' }}>
              <Button
                style={{ marginTop: '20px' }}
                text={intl('audit.attach.import', '导入附件')}
                type="success"
                onClick={async () => {
                  const result = await window.electronComponents.openFilesDialog();
                  if (result.canceled) return;
                  setFilePaths(result.filePaths);
                }}
              />
              <div>待上传附件：</div>
              <ScrollView scrollByThumb={true} direction="vertical" height="10%">
                <List
                  dataSource={filePaths}
                // renderItem={(item) => (
                //   <List.Item>
                //     <span>{item}</span>
                //   </List.Item>
                // )}
                />
              </ScrollView>
            </div>

            <div
              style={{
                display: 'flex',
                position: 'absolute',
                bottom: '10px',
                right: '20px',
              }}
            >
              <Button
                text={intl('audit.cancel', '取消')}
                width={88}
                height={30}
                style={{ marginRight: '10px' }}
                onClick={() => {
                  setImportPopup(false);
                  setFilePaths([]);
                }}
              />
              <Button
                text={intl('audit.ok', '确定')}
                width={88}
                height={30}
                onClick={async () => {
                  const res = await importAttachFromPlatform(
                    filePaths,
                    dbname,
                    zcbfid,
                    username,
                    usercode,
                    "0",
                    sjxmbh
                  );
                  if (res.success) {
                    setImportPopup(false);
                    setFilePaths([]);
                    const resFilter = resDataFilter(res.data);
                    if (resFilter.success) {
                      const { reDataArr } = resFilter;
                      if (reDataArr.tempSucc.length) {
                        notify('导入成功', 'success', 2000);
                        await attachListRefresh();
                        if (XMType === '单机审计项目') return;
                        reDataArr.tempSucc.forEach((item: any) => {
                          syncCpasexeFJ({
                            usercode,
                            password,
                            zcbfid,
                            BusType: 1,
                            BusID: item.fj
                          });
                        });
                      };
                      if (reDataArr.tempError.length) {
                        return errorBouncedRefChangeNameRef.current.show({
                          args: {
                            codes: true,
                            dbname,
                            dgnd: '',
                            pupopType: 'fj',
                            data: reDataArr.tempError,
                          },
                          okCallback: async (tempData: any[]) => {
                            // console.log(tempData, '@@@ okCallback');
                            if (tempData.length > 0) {
                              const resUpdate = await importAttachFromPlatform(
                                tempData[1],
                                dbname,
                                zcbfid,
                                username,
                                usercode,
                                "0",
                                sjxmbh,
                                tempData[0],
                              );
                              if (resUpdate.success) {
                                const resFilterUpdate = resDataFilter(resUpdate.data);
                                if (resFilterUpdate.success) {
                                  const { reDataArr } = resFilterUpdate;
                                  if (reDataArr.tempSucc.length) {
                                    notify('导入成功', 'success', 2000);
                                    await attachListRefresh();
                                    if (XMType === '单机审计项目') return;
                                    reDataArr.tempSucc.forEach((item: any) => {
                                      syncCpasexeFJ({
                                        usercode,
                                        password,
                                        zcbfid,
                                        BusType: 1,
                                        BusID: item.fj
                                      });
                                    });
                                  };
                                }
                              } else {
                                notify('导入失败', 'error', 3000);
                              }
                            } else {
                              await attachListRefresh();
                            }
                          },
                          cancelCallback: () => {
                            attachListRefresh();
                          },
                        });
                      }
                    } else {
                      notify('导入失败', 'error', 2000);
                    }
                  }
                }}
              />
            </div>
          </div>
        )}
      /> */}
      {/*  <DevDefaultPopup.Input ref={InputDialogRef} /> */}
      <DevDefaultPopup.Input ref={InputDialogRef} />
      <ErrorBounced ref={tplDialogRef} />
      <ErrorBouncedChangeName ref={errorBouncedRefChangeNameRef} />
      <AttributeDrawer ref={AttributeRef} fjRefreshEvents={(r: boolean) => { if (r) { attachListRefresh() } }} />
      {/* 附件平台弹窗测试 */}
      {/* <AttachPopUp /> */}
    </div>
  );
};


export default AuditAttach;

